<div class="proDets">
    <img class="off" src="img/temp/off.jpg" />
    <div class="tit clearfix">
        <h4 class="fl">【最家】非洲菊仿真花干花</h4>
        <span id="sprice" class="fr">￥17.90</span>
    </div>
    <div class="proCon clearfix">
        <div class="proImg fl">
            <img id="zhutu" class="list" src="img/temp/proDet.jpg"  />
            <div class="smallImg clearfix">
                <img src="img/temp/proDet01.jpg" data-src="img/temp/proDet01_big.jpg">
                <img src="img/temp/proDet02.jpg" data-src="img/temp/proDet02_big.jpg">
                <img src="img/temp/proDet03.jpg" data-src="img/temp/proDet03_big.jpg">
                <img src="img/temp/proDet04.jpg" data-src="img/temp/proDet04_big.jpg">
            </div>
        </div>
        <div class="fr">
            <div class="proIntro">
                <p>颜色分类</p>
                <div class="smallImg clearfix categ">
                    <p class="fl"><img class="yanse" src="img/temp/prosmall01.jpg" alt="白瓷花瓶+20支快乐花" ></p>
                    <p class="fl"><img class="yanse" src="img/temp/prosmall02.jpg" alt="白瓷花瓶+20支兔尾巴草" ></p>
                    <p class="fl"><img class="yanse" src="img/temp/prosmall03.jpg" alt="20支快乐花"></p>
                    <p class="fl"><img class="yanse" src="img/temp/prosmall04.jpg" alt="20支兔尾巴草" ></p>
                </div>
                <p>数量</p>
                <div class="num clearfix">
                    <img class="fl sub" src="img/temp/sub.jpg">
                    <span class="fl">1</span>
                    <img class="fl add" src="img/temp/add.jpg">
                    <p class="please fl">请选择商品属性!</p>
                </div>
            </div>
            <div class="btns clearfix">
                <a th:if="${session.names} eq null" href="login.html"><p class="buy fl">立即购买</p></a>
                <a th:if="${session.names} ne null"><p id="c" class="buy fl">立即购买</p></a>
                <a th:if="${session.names} eq null" href="login.html"  class="gouwu"><p class="cart fr">加入购物车</p></a>
                <a th:if="${session.names} ne null" href="#2"  class="gouwu"><p class="cart fr">加入购物车</p></a>
            </div>
            <a class="commid" style="display: none"></a>
            <script>
                $(".gouwu").click(function(){
                    $.ajax({
                        url:"/count.html",
                        success:function(data){
                            if(data >0){
                                $(".goCart span").text(data);
                            }
                        }
                    });
                });
                //颜色分类id
                var cid;
                $(".proIntro .smallImg img").on("click",function () {
                    cid = $(this).prop("class").replace("yanse","");
                })

                //立即购买
                // $(".goumai").click(function () {
                //     /*//数量
                //     var amount = $(".num .fl:eq(1)").text();
                //     //商品名称
                //     var name = $(".tit h4").text();*/
                //     //商品id
                //     var commid = $("[class='commid']").text();
                //     /*//单价
                //     var sprice = $("#sprice").text().replace("￥","");*/
                //     location.href="jsorder.html?ck="+commid+",";
                // })


                $(".gouwu").click(function () {

                    //数量
                    var amount = $(".num .fl:eq(1)").text();
                    //商品id
                    var commid = $("[class='commid']").text();
                    //单价
                    var sprice = $("#sprice").text().replace("￥","");
                    if(cid!=null&&cid!=""&&cid!=undefined) {
                        var unames1 = $(".unames1").text();
                        if(unames1==null||unames1==undefined||unames1==''){
                            location.href="login.html";
                        }
                        $.ajax({
                            url: "http://localhost:8080/cartadd",
                            data: {"amount": amount, "cid": cid, "commid": commid, "price": sprice}
                        })
                    }

                })
                $(".btns a").click(function(){
                    if($(".categ p").hasClass("on")){
                        if($(this).children().hasClass("buy")){
                            // $(this).attr("href","order.html");
                            //数量
                            var amount = $(".num .fl:eq(1)").text();
                            //商品id
                            var commid = $(".commid").text();
                            //价格
                            var sprice = $("#sprice").text().replace("￥","");
                            location.href='jons.html?amount='+amount+'&commid='+commid+'&price='+sprice+'&cid='+cid;
                        }
                        $(".proIntro").css("border","none");
                        $(".num .please").hide();
                    }else{
                        $(".proIntro").css("border","1px solid #c10000");
                        $(".num .please").show();
                    }
                })
                
                
                $(".num .fl:eq(2)").on("click",function () {
                    if(parseInt($(".num .fl:eq(1)").text())+1>99){
                        return false;
                    }
                    $(".num .fl:eq(1)").text(parseInt($(".num .fl:eq(1)").text())+1);
                })
                $(".num .fl:eq(0)").on("click",function () {

                    if(parseInt($(".num .fl:eq(1)").text())-1<1){
                        return false;
                    }
                    $(".num .fl:eq(1)").text(parseInt($(".num .fl:eq(1)").text())-1);
                })

            </script>
        </div>
    </div>
    <a class="more" href="proDetail.html">查看更多细节</a>
</div>